import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class Bean implements Delayed {
    private int id;
    private long beginTime;
    private long delayTime;
    public Bean(long delayTime, int id) {
        this.beginTime = System.currentTimeMillis();
        this.delayTime = delayTime;
        this.id = id;
    }
    public int compareTo(Delayed o){
        long result = this.getDelay(TimeUnit.MILLISECONDS)-o.getDelay(TimeUnit.MILLISECONDS);
        return (int)result;

    }
    public long getDelay(TimeUnit unit){
        long last = beginTime+this.delayTime-System.currentTimeMillis();
        return last;
    }
    public String toString() {
        return "id:"+id +"，延迟"+ delayTime +"毫秒。。。";

    }
}
